package com.atm.thirdplt.web.controller.busi;

import com.alibaba.fastjson.JSON;
import com.atm.thirdplt.common.core.domain.AjaxResult;
import com.atm.thirdplt.common.core.domain.ca.CaUploadPdfParm;
import com.atm.thirdplt.common.core.domain.his.TestWriteHis;
import com.atm.thirdplt.service.AtmCaService;
import com.atm.thirdplt.service.AtmHisConfigService;
import com.atm.thirdplt.service.impl.AtmCaServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * CA自动签名 控制层
 *
 * @author：l
 * @date：2023/02/17
 */
@Slf4j
@RestController
@RequestMapping("ca")
public class AtmCaController {
    /**
     * 服务对象
     */
    @Resource
    private AtmCaService atmCaServiceImpl;

    /**
     * 获取签名图片
     *
     * @return
     */
    @GetMapping("/queryCaUserImg")
    public AjaxResult queryCaUserImg(@RequestParam("caUserId") String caUserId) {
        //log.info("CA自动签名ID: " + caUserId);
        return atmCaServiceImpl.queryCaUserImg(caUserId);
    }

    /**
     * 添加签名任务-扫码类型
     *
     * @param parmMap 参数
     * @return
     */
    @PostMapping("/addCaSign")
    public AjaxResult addCaSign(@RequestBody Map<String,String> parmMap) {
        //log.info("添加签名任务parm:【{}】", JSON.toJSONString(parmMap));
        return atmCaServiceImpl.addCaSign(parmMap);
    }

    /**
     * 开启自动签-扫码
     *
     * @return
     */
    @GetMapping("/startAutoSign")
    public AjaxResult startAutoSign() {
        return atmCaServiceImpl.startAutoSign();
    }

    /**
     * 获取签名结果
     *
     * @return
     */
    @GetMapping("/getSignResult")
    public AjaxResult getSignResult(@RequestParam("signDataId") String signDataId) {
        //log.info("签名数据ID: " + signDataId);
        return atmCaServiceImpl.getSignResult(signDataId);
    }

    /**
     * 上传PDF
     *
     * @param pdfParm 参数
     * @return
     */
    @PostMapping("/uploadCaPdf")
    public AjaxResult uploadCaPdf(@RequestBody CaUploadPdfParm pdfParm) {
        return atmCaServiceImpl.uploadCaPdf(pdfParm);
    }


    /**
     *  撤销PDF
     *
     * @param pdfParmList 参数
     * @return
     */
    @PostMapping("/removeCaPdf")
    public AjaxResult removeCaPdf(@RequestBody List<CaUploadPdfParm> pdfParmList) {
        log.info("撤销PDFparm:【{}】", JSON.toJSONString(pdfParmList));
        return atmCaServiceImpl.removeCaPdf(pdfParmList);
    }
}